package com.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @Title: AppApplication
 * @Description: []
 * @Author lei.cheng
 * @Date 2024/12/4
 */
@SpringBootApplication
public class AppApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext content = SpringApplication.run(AppApplication.class, args);
        JdbcTemplate jdbcTemplate = content.getBean(JdbcTemplate.class);
        jdbcTemplate.query("select * from user", new RowCallbackHandler() {
            //映射每行数据
            @Override
            public void processRow(ResultSet rs) throws SQLException {
                System.out.println(rs.getString("name"));
                System.out.println(rs.getString("age"));
            }
        });
    }
}
